import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:speed_random/app_styles.dart';
import 'package:speed_random/common/common_fuc.dart';
import 'package:speed_random/global_data.dart';
import 'package:speed_random/pages/home/rand_com/com_results/logic.dart';
import 'package:speed_random/pages/home/rand_com/com_results/state.dart';
import 'package:share_plus/share_plus.dart';

class ItemResultsSpinWheel extends StatelessWidget {
  final ComResultsLogic logic;
  final ComResultsState state;
  final Map<String, dynamic> numbers;
  final Color textColor;
  final Color bgColor;
  final Function({String newShareText,String newcopyText}) onShareTextChanged; // 添加回调函数

  const ItemResultsSpinWheel({
    Key? key,
    required this.logic,
    required this.state,
    required this.numbers,
    this.textColor = AppStyles.colorPageText,
    this.bgColor = AppStyles.colorPagebg,
    required this.onShareTextChanged, // 必须传入回调函数
  }) : super(key: key);




  @override
  Widget build(BuildContext context) {
   var newShareText = "${state.randComArgs.value.title}\n${numbers["list"]}";
    onShareTextChanged(newShareText: newShareText,newcopyText: newShareText);
    return Column(
      mainAxisAlignment: MainAxisAlignment.center,
      crossAxisAlignment: CrossAxisAlignment.center,
      children: [
        Text(
          state.randComArgs.value.title,
          style:  TextStyle(
            fontSize: 18,
            fontWeight: FontWeight.bold,
            color: textColor,
          ),
        ),
        const SizedBox(height: 10),
        Row(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [

            numbers["list"].length>20?
            Expanded(child: Text(
              numbers["list"],
              style:  TextStyle(
                fontSize: 18,
                fontWeight: FontWeight.bold,
                color: textColor,
              ),
            ))
                : Text(
              numbers["list"],
              style:  TextStyle(
                fontSize: 18,
                fontWeight: FontWeight.bold,
                color: textColor,
              ),
            ),
          ],
        ),


      ],
    );
  }
}
